package com.fy.admin.controller;


import com.fy.admin.feign.TicketManagementFeignService;
import com.fy.admin.vo.TicketVo;
import com.fy.common.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ticket")
@Api(tags = "门票管理")
@RefreshScope
public class TicketManagementController {
    @Autowired
    TicketManagementFeignService service;

    @ApiOperation("查询所有")
    @GetMapping(value = "/findAll/{pageSize}/{limit}")
    public CommonResult findAll(@PathVariable Integer pageSize, @PathVariable Integer limit) {
        return CommonResult.success(service.findAll(pageSize, limit));
    }

    @ApiOperation("添加门票")
    @PostMapping(value = "/add")
    public CommonResult add(@RequestBody TicketVo ticketVo) {
        return service.add(ticketVo);
    }

    @ApiOperation("编辑门票")
    @PostMapping(value = "/edit")
    public CommonResult edit(@RequestBody TicketVo ticketVo) {
        return service.edit(ticketVo);
    }

    @ApiOperation("删除门票")
    @DeleteMapping(value = "/delete/{id}")
    public CommonResult delete(@PathVariable Integer id) {
        return service.delete(id);
    }

    @ApiOperation("根据门票ID查询")
    @GetMapping(value = "/findById/{id}")
    public CommonResult findById(@PathVariable Integer id) {
        return CommonResult.success(service.findById(id));
    }
}
